#ifndef VD_INTERNAL_H
#define VD_INTERNAL_H

#include <linux/fs.h>

#include "device-mapper.h"

#define VD_NAME "virtual-disks"

#define VDERR(f, arg...) printk(KERN_ERR VD_NAME ": " VD_MSG_PREFIX ":" f "\n", ## arg)
#define VDWARN(f, arg...) printk(KERN_WARNING VD_NAME ": " VD_MSG_PREFIX ":" f "\n", ## arg)
#define VDINFO(f, arg...) printk(KERN_INFO VD_NAME ": " VD_MSG_PREFIX ":" f "\n", ## arg)

#define vd_div_up(n, sz) (((n) + (sz) - 1) / (sz))

#define vd_sector_div_up(n, sz) ( \
{ \
    sector_t _r = ((n) + (sz) - 1); \
    sector_div(_r, (sz)); \
    _r; \
} \
)

struct raid_data;

struct target_dev{
    struct list_head list;
    atomic_t count;
    int mode;
    struct raid_data *device;
    char name[16];

};

#define vd_round_up(n, sz) (vd_div_up((n), (sz)) * (sz))

int vd_interface_init(void);
void vd_interface_exit(void);

int vd_linear_init(void);
void vd_linear_exit(void);

/* vd-target.c */
struct target_type *vd_get_target_type(const char *name);
void vd_put_target_type(struct target_type *t);

/* vd-table.c */
struct vd_target *vd_table_find_target(struct vd_table *t, sector_t sector);

#endif

